package com.supermali.behavior.move.land;

import com.supermali.behavior.move.MoveBehavior;
import com.supermali.entity.MapImageAbstract;
import com.supermali.entity.npc.monistor.MonistorAbstract;

/**
 * 怪物走动
 * */
public class MonitorMove extends MoveBehavior {

    int status = 0;

    private MapImageAbstract monistorAbstract;

    private double v =0;

    int xdirect;//当前的运动方向为正方向

    public MonitorMove(MapImageAbstract monistorAbstract) {
        this.monistorAbstract = monistorAbstract;
        v = 60d/3000;
        xdirect=1;
    }

    @Override
    public void move(long delta) {
        // 3秒钟 24个px
        double x = monistorAbstract.getX();
        double y = monistorAbstract.getY();
        double dv = this.v * delta * xdirect;
        x+= dv;
        monistorAbstract.setX(x);
        if(x<0){
            status = 0;
        }
        if(y<-300){
            status=0;
        }
    }

    @Override
    public boolean isOver() {
        return status==0?true:false;
    }

    @Override
    public void setXdirect(int xdirect) {
        this.xdirect = xdirect;
    }

    @Override
    public void start() {
        this.status = 1;
    }

    @Override
    public void setV(double v) {
        this.v = v;
    }
}
